----------------------------------------------------------------------------
-- Class module.
-- Create a new Class type from our base class
-- @classmod Class
-- @author recursor (https://twitter.com/recursor)
-- @license CC BY-NC-SA 4.0
----------------------------------------------------------------------------

local Class = {}

Class.__index = Class

-- default implementation
function Class:new()
end

--- Create new object.
-- Create new instance of object.
-- @function derive
-- @tparam string name Name of object.
function Class:derive(name)
    assert(name ~= nil, 'parameter name must not be nil!')
    assert(type(name) == 'string', 'parameter name class must be string!')
    local cls = {}
    cls['__call'] = Class.__call
    cls.name = name
    cls.__index = cls
    cls.super = self
    setmetatable(cls, self)
    return cls
end

--- TODO
function Class:__call(...)
    local inst = setmetatable({}, self)
    inst:new(...)
    return inst
end

return Class
